package com.hospital.common.core.exception;

import lombok.extern.slf4j.Slf4j;

/**
 * @author lvyao
 * @description 异常打印模板类
 * @date 2022/6/27
 */
@Slf4j
public class ExceptionPrint {
    /**
     * HL7服务消息打印模板
     *
     * @param type
     * @param param
     * @param body
     * @param hl7Message
     * @param describe
     * @param sendUrl
     */
    public static void printString(String type, String param, String body, String hl7Message, String describe, String sendUrl) {
        String desc = null;
        switch (describe) {
            case "1":
                desc = "HL7消息推送失败,网页返回状态不是200";
                break;
            case "2":
                desc = "HL7消息推送成功,返回MSA|AA|";
                break;
            case "3":
                desc = "HL7消息推送成功，但厂商返回消息异常";
                break;
            case "4":
                desc = "HL7消息推送过程中出现异常报错";
                break;
            case "5":
                desc = "配置表参数‘HL7_SERVICE_REPLACE’或‘HL7_LOG_REPLACE’未配置请查看！";
                break;
            default:
                desc = "JSON转换或HL7消息转换异常报错";
                break;
        }
        log.info("=======消息类型（1-计费？0-未计费？2-撤销）" + type + "\r\n" +
                "=======描述：" + desc + "\r\n" +
                "=======推送地址：" + sendUrl + "\r\n" +
                "=======入参：" + param + "\r\n" +
                "=======推送地址返回：" + body + "\r\n" +
                "=======生成得HL7消息：" + hl7Message);
    }

    public static void printCommString(String functionName, String param, String code, String message, String startTime, String endTime, String allTime) {
        log.info("\r\n" + "=======方法名：" + functionName + "\r\n" +
                "=======入参：" + param + "\r\n" +
                "=======处理结果编码：" + code + "\r\n" +
                "=======处理结果描述：" + message + "\r\n" +
                "=======开始时间：" + startTime + "\r\n" +
                "=======结束时间：" + endTime + "\r\n" +
                "=======总耗时：" + allTime);

    }

    public static void printCommString(String value, String startTime, String endTime) {
        log.info("\r\n" + "=======密钥workKey：" + value + "\r\n" +
                "=======开始时间：" + startTime + "\r\n" +
                "=======结束时间：" + endTime);
    }

    public static void printCommErrorString(String functionName, String param, String code, String message, String startTime, String endTime, String allTime) {
        log.error("\r\n" + "=======方法名：" + functionName + "\r\n" +
                "=======入参：" + param + "\r\n" +
                "=======处理结果编码：" + code + "\r\n" +
                "=======处理结果描述：" + message + "\r\n" +
                "=======开始时间：" + startTime + "\r\n" +
                "=======结束时间：" + endTime + "\r\n" +
                "=======总耗时：" + allTime);

    }

    public static void printCommErrorString(String functionName, String param, String code, String message, String msgType, String lastRes, String inpParam, String des, String enc) {
        log.error("\r\n" + "=======方法名：" + functionName + "\r\n" +
                "=======消息类型：" + msgType + "\r\n" +
                "=======入参：" + param + "\r\n" +
                "=======入参明文：" + inpParam + "\r\n" +
                "=======处理结果编码：" + code + "\r\n" +
                "=======处理结果描述：" + message + "\r\n" +
                "=======" + lastRes + "\r\n");

    }

    public static void printCommErrorString(String functionName, String param, String code, String message, String msgType, String lastRes, String insurParam, String des) {
        log.error("\r\n" + "=======方法名：" + functionName + "\r\n" +
                "=======消息类型：" + msgType + "\r\n" +
                "=======接口入参：" + param + "\r\n" +
                "=======推送医保的入参：" + insurParam + "\r\n" +
                "=======处理结果编码：" + code + "\r\n" +
                "=======处理结果描述：" + message + "\r\n" +
                "=======" + lastRes + "\r\n");

    }


}
